﻿using SmartRS.com.vn.smartrs.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartRS.com.vn.smartrs.controller
{
    class FoodOrderController
    {
        public static FoodOrder getFoodOrderFromListById(IList<FoodOrder> listFoodOrder, long id)
        {
            foreach (FoodOrder foodOrder in listFoodOrder)
            {
                if (foodOrder.foodOrderId == id)
                {
                    return foodOrder;
                }
            }
            return null;

        }

        public static long calculatorCharge(IList<FoodOrder> listFoodOrder)
        {
            if (listFoodOrder == null || listFoodOrder.Count <=0)
            {
                return 0L;
            }
            long priceTotal = 0;
            long discountTotal = 0;
            foreach (FoodOrder foodOrder in listFoodOrder)
            {
                priceTotal += (foodOrder.priceWhenOrder * foodOrder.quantityOrder);

                discountTotal += foodOrder.discountValue;
            }


            return priceTotal - discountTotal;
        }


    }
}
